<template>
  <div>
    <p>{{ minutes }}分{{ seconds }}秒</p>

  </div>
</template>

<script>
export default {
  name: "countdownTimer",
  data() {
    return {
      remainingTime: 600, // 倒计时初始值为600秒 (10分钟)
      timerId: null
    };
  },
  computed: {
    minutes() {
      return Math.floor(this.remainingTime / 60);
    },
    seconds() {
      return this.remainingTime % 60;
    }
  },
  mounted() {
    this.startCountdown();
  },
  methods: {
    startCountdown() {
      this.timerId = setInterval(() => {
        if (this.remainingTime > 0) {
          this.remainingTime--;
        } else {
          clearInterval(this.timerId);
        }
      }, 1000);
    }
  },
  beforeDestroy() {
    clearInterval(this.timerId);
  }
}
</script>

<style scoped>

</style>
